import os, sys
from spreadsheetdb import GoogleSpreadsheet
import spreadsheetdb.uoitdoc as uoitdoc
from pprint import pprint, pformat
from sqlite3 import connect

def make_smash(username, password):

  google = GoogleSpreadsheet(username, password)
  accounts = uoitdoc.listaccounts(google)
  root = "../../pages"
  lines = []
  for name, account in accounts.items():
    cache = os.path.join(root, name, "data.json")
    data = uoitdoc.loadpages(google,    # forcehtml silences the exception
           account, cache, forcehtml=1) # if data is cached
    lines.append(pformat(data))

  return "\n".join(lines)
